package ssau.knyazev.modules;

import java.util.Random;

public class Generator {

	protected Generator() {	}

	public static float[] generateVector(int length){
		return generateVector(length, 1, 0);
	}
	
	public static float[] generateVector(int length, int maxValue, int minValue) {
		float[] res = new float[length];
		Random rnd = new Random();
		for (int i = 0; i < length; i++) {
			res[i] = maxValue - rnd.nextFloat()*(maxValue - minValue);
		}
		return res;
	}
	
	public static float[][] generateMatrix(int width) {
		return generateMatrix(width, width);
	}
	
	public static float[][] generateMatrix(int width, int height) {
		return generateMatrix(width, height, 1, 0);
	}
	
	public static float[][] generateMatrix(int width, int maxValue, int minValue) {
		return generateMatrix(width, width, maxValue, minValue);
	}
	
	public static float[][] generateMatrix(int width, int height, int maxValue, int minValue) {
		float[][] res = new float[height][width];
		Random rnd = new Random();
		for (int i = 0; i < height; i++){
			for (int j = 0; j < width; j++){
				res[i][j] = (int) (maxValue - rnd.nextFloat()*(maxValue - minValue));
			}
		}
		return res;
	}
	
	public static float[] generateSimpleVector(int length){
		float[] res = new float[length];
		for (int i = 0; i < res.length; i++){
			res[i] = i % 5 + 2;
		}
		return res;
	}
	
	public static float[][] generateSimpleMatrix(int width){
		float[][] res = new float[width][width];
		float k = 0;
		for (int i = 0; i < res.length; i++){
			for (int j = 0; j < res.length; j++){
				res[i][j] = (float) (k/6 + k*Math.cos(k));
				k++;
			}
		}
		return res;
	}
}
